<?php

namespace App\Service\UserOperation;

use App\Constants\ErrorCode;
use App\Exception\ApiException;
use App\Service\BaseService;

class CoinBaseService extends BaseService
{
    public function handle()
    {
        $this->actionUserId = $this->getUserId();

        $type = $this->request->input('type', 0);

        $factory = new CoinCheckFactory();
        switch ($type) {
            case 1:
                $service = $factory->checkRecharge();

                $service->money = $this->request->input('pay_money', 0);
                break;
            case 2:
                $service = $factory->checkSendGift();

                $service->giftId = $this->request->input('gift_id', 0);
                $service->giftNum = $this->request->input('gift_num', 0);
                break;
            default:
                throw new ApiException('操作异常!', ErrorCode::PARAMETER_ERROR);
        }

        $service->actionUserId = $this->actionUserId;
        $service->check();

        return ['msg' => '无限制'];
    }
}